package com.cskaoyan.mall.product.controller;


import com.cskaoyan.mall.common.result.Result;
import com.cskaoyan.mall.product.dto.CategoryHierarchyDTO;
import com.cskaoyan.mall.product.dto.TrademarkDTO;
import com.cskaoyan.mall.product.query.CategoryTrademarkParam;
import com.cskaoyan.mall.product.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("admin/product")
public class AdminTrademarkController {

    @Autowired
    CategoryService categoryService;

    @GetMapping("/baseCategoryTrademark/findTrademarkList/{thirdLevelCategoryId}")
    public Result findTrademarkList(@PathVariable Long thirdLevelCategoryId){
        List<TrademarkDTO> trademarkDTOList = categoryService.findTrademarkList(thirdLevelCategoryId);
        return Result.ok(trademarkDTOList);
    }

    @GetMapping("/baseCategoryTrademark/findCurrentTrademarkList/{thirdLevelCategoryId}")
    public Result findCurrentTrademarkList(@PathVariable Long thirdLevelCategoryId){
        List<TrademarkDTO> trademarkDTOList = categoryService.findUnLinkedTrademarkList(thirdLevelCategoryId);
        return Result.ok(trademarkDTOList);
    }

    @PostMapping("/baseCategoryTrademark/save")
    public Result save(@RequestBody CategoryTrademarkParam categoryTrademarkParam){
        categoryService.save(categoryTrademarkParam);
        return Result.ok();
    }

    @DeleteMapping("/baseCategoryTrademark/remove/{thirdLevelCategoryId}/{trademarkId}")
    public Result remove(@PathVariable Long thirdLevelCategoryId,@PathVariable Long trademarkId){
        categoryService.remove(thirdLevelCategoryId,trademarkId);
        return Result.ok();
    }
}
